package com.suxin.plugin.intergration.factory.process;

import com.suxin.plugin.intergration.factory.PluginRegistryInfo;
import com.suxin.plugin.intergration.factory.process.pip.PluginPipeProcessor;
import com.suxin.plugin.intergration.factory.process.pip.bean.BasicBeanProcessor;
import com.suxin.plugin.intergration.factory.process.pip.classs.PluginClassProcess;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Tang
 * @classname PluginPipeProcessorFactory
 * @description [  ]
 * @date 2022/7/21 21:26
 */
public class PluginPipeProcessorFactory implements PluginPipeProcessor{

    private final List<PluginPipeProcessor> pluginPipeProcessorList = new ArrayList<>(10);

    private final ApplicationContext applicationContext;

    public PluginPipeProcessorFactory(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public void initialize() throws Exception {
        pluginPipeProcessorList.add(new PluginClassProcess());
        pluginPipeProcessorList.add(new BasicBeanProcessor(applicationContext));
    }

    @Override
    public void registry(PluginRegistryInfo pluginRegistryInfo) throws Exception {
        for (PluginPipeProcessor pluginPipeProcessor : pluginPipeProcessorList) {
            pluginPipeProcessor.registry(pluginRegistryInfo);
        }
    }

    @Override
    public void unRegistry(PluginRegistryInfo pluginRegistryInfo) {

    }
}
